package com.firebugsoft.generator.dubbo.provider.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.firebugsoft.generator.dubbo.api.service.IGeneratorService;
import com.firebugsoft.generator.dubbo.provider.component.SnowflakeComponent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;

/**
 * 生成器服务
 * 
 * @author felix
 */
@Service
public class GeneratorService implements IGeneratorService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource
    private SnowflakeComponent snowflakeComponent;

    @Override
    public long getUniqueIdBySnowflake() {
        long id = snowflakeComponent.getId();
        logger.info("unique id: {}", id);
        return id;
    }
}
